{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 量子近似优化算法\n",
    "\n",
    "[![](https://gitee.com/mindspore/docs/raw/master/resource/_static/logo_source.png)](https://gitee.com/mindspore/docs/blob/master/docs/mindquantum/docs/source_zh_cn/quantum_approximate_optimization_algorithm.ipynb)\n",
    "\n",
    "## 概述\n",
    "\n",
    "量子近似优化算法（Quantum Approximate Optimization Algorithm，QAOA）是利用量子计算机来近似解决组合优化问题的量子算法，最早由Farhi等人于2014年提出。在本文档里，我们将利用QAOA算法来解决最大割问题（Max-Cut），来熟悉MindQuantum中量子线路的搭建和训练。\n",
    "\n",
    "> 本文档适用于CPU环境。\n",
    "> 你可以在这里找到完整的可运行的样例代码：<https://gitee.com/mindspore/mindquantum/blob/master/tutorials/source/quantum_approximate_optimization_algorithm.py>。\n",
    "\n",
    "## 环境准备\n",
    "\n",
    "本文档所需要的额外库：\n",
    "\n",
    "- networkx\n",
    "\n",
    "> `networkx`是创建、操作和研究复杂网络的结构、动态和功能库。可通过如下代码来进行安装。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```bash\n",
    "pip3 install networkx\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Max-Cut问题描述\n",
    "\n",
    "Max-Cut问题是图论中的一个NP-complete问题，它需要将一个图中的顶点分成两部分，并使得两部分被切割的边最多。如下图（a），一个图由五个顶点构成，相互连接的边为```(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (0, 4)```。为了使得被切割的边最多，我们尝试通过（b）图的分割，将1、2、4分为一组，0、3分成另一组，因此可得到被切割的边有5条。后面我们将用穷举法验证这个解是否正确。当图中顶点较少时，我们可以在较短时间内通过穷举法找到最大的切割边数，但当图中顶点增多时，我们很难找到有效的经典算法来解决Max-Cut问题，因为这类NP-complete问题很有可能不存在多项式时间算法。但尽管精确解不容易得到，我们却可以想办法在多项式时间内找到问题的一个近似解，这就是近似优化算法。下面，我们介绍怎么将Max-Cut问题转化为一个哈密顿量的基态能量求解问题。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![max cut](https://gitee.com/mindspore/docs/raw/master/docs/mindquantum/docs/source_zh_cn/images/Max_Cut.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Max-Cut问题量子化\n",
    "\n",
    "这里我们将图中的每个顶点赋予一个量子比特，当顶点被分到左边时，我们将该顶点上的量子比特设置为$\\left|0\\right>$态，同理，右边为$\\left|1\\right>$态，当两个顶点被分到不同的集合中时，这两个顶点上的比特将处于不同的量子态。例如对于第0个顶点和第1个顶点，当其连线被切割时，两个顶点上的比特对应的量子态可以表示为$|01\\rangle$（顶点1：左，顶点0：右）或$|10\\rangle$（顶点1：右，顶点0：左）；若它们被分到同一边，则对应量子态为$|00\\rangle$或$|11\\rangle$。因此我们只要找到一个哈密顿量$H$使得：当有连线的两个顶点处于不同量子态时，哈密顿量的期望值为-1，即\n",
    "\n",
    "$$\n",
    "\\langle 01|H|01\\rangle=-1,\\quad \\langle 10|H|10\\rangle=-1\n",
    "$$\n",
    "\n",
    "而当有连线的顶点处于相同量子态时，哈密顿量的期望值为0，即\n",
    "\n",
    "$$\n",
    "\\langle 00|H|00\\rangle=0,\\quad \\langle 11|H|11\\rangle=0\n",
    "$$\n",
    "\n",
    "随后只要使哈密顿量的期望值最小化，就可以找到最大切割边数，以及此时对应的分组情况。之所以将不同量子态时的期望值设为-1，是因为在量子神经网络的训练中，Ansatz中的参数的梯度会一直下降，同时测量值也会一直减少，该训练方法就是以找到最小值为目标，这里我们用它来寻找哈密顿量的基态能量。此时，我们选择哈密顿量$H=(Z_1Z_0-1)/2$，这里$Z$为泡利$Z$算符。此时有：\n",
    "\n",
    "$$\n",
    "Z_1Z_0|00\\rangle=|00\\rangle,\\quad Z_1Z_0|11\\rangle=|11\\rangle, \\quad Z_1Z_0|01\\rangle=-|01\\rangle, \\quad Z_1Z_0|10\\rangle=-|10\\rangle\n",
    "$$\n",
    "\n",
    "因此当顶点被分到不同集合时：\n",
    "\n",
    "$$\n",
    "\\left<01\\right|H\\left|01\\right>=\\frac{1}{2}\\left<01\\right|Z_1Z_0\\left|01\\right>-\\frac{1}{2}=-1\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\left<10\\right|H\\left|10\\right>=\\frac{1}{2}\\left<10\\right|Z_1Z_0\\left|10\\right>-\\frac{1}{2}=-1\n",
    "$$\n",
    "\n",
    "而当顶点被分到同一集合中时，不难验证此时：\n",
    "\n",
    "$$\n",
    "\\left<00\\right|H\\left|00\\right>=\\frac{1}{2}\\left<00\\right|Z_1Z_0\\left|00\\right>-\\frac{1}{2}=0\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\left<11\\right|H\\left|11\\right>=\\frac{1}{2}\\left<11\\right|Z_1Z_0\\left|11\\right>-\\frac{1}{2}=0\n",
    "$$\n",
    "\n",
    "因此，我们只要对图中的每条边写出上述哈密顿量，然后将所有边求和，即可写出图对应的哈密顿量$H$，利用量子计算机求得$H$的基态能量与基态，我们就可以得到该图的Max-Cut切割方案与最大切割边数。我们记所有边的集合为$C$，所有边条数为$c$，则哈密顿量可写为：\n",
    "\n",
    "$$\n",
    "H=\\sum_{(i,j)\\in C}(Z_iZ_j-1)/2\n",
    "$$\n",
    "\n",
    "## 导入相关依赖"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from mindquantum.core import Circuit, Hamiltonian, UN, H, ZZ, RX, QubitOperator\n",
    "from mindquantum.framework import MQAnsatzOnlyLayer\n",
    "from mindquantum.simulator import Simulator\n",
    "import networkx as nx\n",
    "import mindspore.nn as nn"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 搭建所需求解的图\n",
    "\n",
    "通过`add_path`可在图中添加边。最后画出图的结构。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAb4AAAEuCAYAAADx63eqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAA4+klEQVR4nO3deViU5eI+8HtmWIZFAlxABcVCxRVFUPZlvq64DbjkVmappaYtHj2mdY6e0vJXqZmaWWmamgvKKLknu7iAGiYKihuiiIgioGwzzO8Pj++JXEHgneX+XNf3ujozw8zN9UVunud9nueVaLVaLYiIiIyEVOwARERE9YnFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERsVE7ABEpNtuFZch4ng20m8UorBUDRu5CdwcbTCsmxMaWpuLHY+o2iRarVYrdggi0j2pVwuwPDYTcefyAABl6krhObmJFFoAwW0bY3KQK9ydbcUJSVQDLD4iesT6I5cxf3c6StUaPO03hEQCyE1kmBPqhjHeLvWWj+hFcKqTiKp4UHpnUVJR+czXarVASYUG83efBQCWH+kFjviISJB6tQAjfjiCkgrNI8/dOxOHWzu/BAA08BwE+54TqzxvYSrD5one6OxkWx9RiWqMqzqJSLA8NhOl6kdLT114C7f3rQCksid+balagxWxmXUZj6hWsPiICMCD1Ztx5/Ieuaan1WqRv2sRZA0awrKt7xO/XqsFYjLykF9cVsdJiV4Mi4+IAAARx7Mf+3hR8g6UZp9Bo4H/gERm9tT3kACIOPH49yHSFSw+IgIApN8orLJlAQDK8y7jTtxa2AaMgZnDy898j1J1JdJziuoqIlGt4KpOIgIAFJaqH3nsfkYSoFGjNOtPlF1NQ/nNSwCAkvNHccfEDHbBbzzmfSrqOirRC2HxERm54uJiJCYmIvPMNUDqWPVJrRaAFqUXj1d5WH03F2XX0h/7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jtt9+gUqkQGxsLb29vKJVKDB48GM2bN3/u91l/5DLm705HqVqDpzWHRALITWSYE+qGMd4uL/4N1DIWHxGRESkuLsb+/fuhUqmwa9cuvPLKK8J1wXbt2kEikTz26x6U3lmUVFQ+92dZmEoxJ7SdzpUfi4+IyEhVVFQIi2NUKhUsLCyEEuzRowek0gcL/1OvFmDED0dQUqERvrYweQeKTx1Axa0sQFuJl/xGwjZg9COfYWEqw+aJ3ujsZFtf39YzcTsDEZGRMjU1rXI3+Y0bN8LMzAwTJ05E8+bN8fbbb2PPnj34NvocStWaKl9bfiMTUrk1ZA0aPfUzStUarIjNrMtvo9o44iMiokdkZmZix44d2LZrP651ewcSE7PHvu7mts9Qcv7IE0d8AGBuIkXSPxU6s9qTIz4iInqEq6srpk+fjtf/vQLm5i9WWBIAESfEPWXmr1h8RET0ROk3CqtsWaiJUnUl0nOKainRi2PxERHRExWWqmvpfSpq5X1qA4uPiIieyEZeOydb2shNa+V9agPP6iQioidyc7SBuckNlKmr7t8rSt2HsqtnUJ57AQBw//wRqO/ehGUbb1i28anyWrmJFG5NG9Rb5mfhiI+IiJ5oaDenxz5edvUM7p0+CE3hgzuwV9y8hHunD6I89+Ijr9UCGOrx+PcRA7czEBHRU038JQUHzuY+9ZiyJ5FIgD7tHbByjGftB6shjviIiOippgS7Qm5Ss1scyU1kmBzsWsuJXgyLj4iInsrd2RZzQt1gYVq9ynhwVqebTh1XBnBxCxERPYeHB03z7gxERGRUTmUXYEVsJmIy8iDBg83pDz28H19I28aYHOyqcyO9h1h8RERUbfnFZYg4kY30nCIUllbARm4Kt6YNMNSDd2AnIiLSKVzcQkRERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERoXFR0RERuX/AyOl0kFOs5cVAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "g = nx.Graph()\n",
    "nx.add_path(g, [0, 1])\n",
    "nx.add_path(g, [1, 2])\n",
    "nx.add_path(g, [2, 3])\n",
    "nx.add_path(g, [3, 4])\n",
    "nx.add_path(g, [0, 4])\n",
    "nx.add_path(g, [0, 2])\n",
    "nx.draw(g, with_labels=True, font_weight='bold')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如上图，我们得到一个由5个节点和6条边构成的图结构。\n",
    "\n",
    "接下来我们用穷举法来看看所有情况的切割边数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "one size: [0] cut= 3\n",
      "one size: [1] cut= 2\n",
      "one size: [1, 0] cut= 3\n",
      "one size: [2] cut= 3\n",
      "one size: [2, 0] cut= 4\n",
      "one size: [2, 1] cut= 3\n",
      "one size: [3] cut= 2\n",
      "one size: [3, 0] cut= 5\n",
      "one size: [3, 1] cut= 4\n",
      "one size: [3, 2] cut= 3\n",
      "one size: [4] cut= 2\n",
      "one size: [4, 0] cut= 3\n",
      "one size: [4, 1] cut= 4\n",
      "one size: [4, 2] cut= 5\n",
      "one size: [4, 3] cut= 2\n"
     ]
    }
   ],
   "source": [
    "for i in g.nodes:\n",
    "    print('one size:', [i], 'cut=', nx.cut_size(g, [i]))            # 一组1个节点、另一组4个节点的所有情况\n",
    "    for j in range(i):\n",
    "        print('one size:', [i, j], 'cut=', nx.cut_size(g, [i, j]))  # 一组2个节点、另一组3个节点的所有情况"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从以上结果可以看出，穷举法得到的最大切割边数为5，如果对节点分组的左右进行区分，则一共有4种分组方法可以使切割边数最大，即该问题有4个简并解。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## QAOA算法整体流程\n",
    "\n",
    "1. 搭建QAOA量子线路，其中ansatz线路包含可以训练的参数\n",
    "2. 初始化线路中的参数\n",
    "3. 运行该量子线路，得到量子态$|\\psi\\rangle$\n",
    "4. 计算目标哈密顿量$H_C$的期望值$\\langle\\psi|H_C|\\psi\\rangle$\n",
    "5. 根据第4步的结果，使用Adam优化器优化线路中参数\n",
    "6. 重复3-5步，直到第4步结果基本不再变化\n",
    "7. 根据第4步的结果，算出目标问题的近似解\n",
    "\n",
    "在该流程中，第2-6步都可以由MindSpore和MindQuantum中现成的包和函数来实现，因此我们将重点关注第1步——量子线路的搭建。\n",
    "\n",
    "![Flowchart](https://gitee.com/mindspore/docs/raw/master/docs/mindquantum/docs/source_zh_cn/images/QAOA_Flowchart.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 搭建QAOA量子线路\n",
    "\n",
    "先前提到，我们需要将问题对应的哈密顿量\n",
    "\n",
    "$$\n",
    "H_C=\\sum_{(i,j)\\in C}(Z_iZ_j-1)/2\n",
    "$$\n",
    "\n",
    "最小化来找到问题的解，也就是说我们要找到该哈密顿量的基态。对此我们可以采用量子绝热演化的方法，使系统先处于某一简单哈密顿量$H_B$的基态上，然后使简单的哈密顿量$H_B$绝热地、缓慢地演化至某一复杂的哈密顿量$H_C$，根据绝热定理，系统将始终保持在哈密顿量的基态上，最终达到复杂哈密顿量$H_C$的基态。\n",
    "\n",
    "我们将要搭建的量子线路就是采用以上思路，选取初始简单哈密顿量为\n",
    "\n",
    "$$\n",
    "H_B=\\sum_i X_i\n",
    "$$\n",
    "\n",
    "并将量子线路制备到$H_B$的基态$|s\\rangle=|+\\rangle^{\\otimes n}$，这里通过对所有量子比特作用`Hadamard`门即可实现。然后连接ansatz含参线路，通过不断地优化其中参数可以使得ansatz线路越来越接近真实绝热演化的效果，最终得到的量子线路可以视为模拟近似了一个真实的绝热演化过程。\n",
    "\n",
    "### ansatz线路\n",
    "\n",
    "在量子绝热演化中，首先选取初始哈密顿量\n",
    "\n",
    "$$\n",
    "H_B=\\sum_i X_i\n",
    "$$\n",
    "\n",
    "并使系统处于$H_B$的基态$|s\\rangle=|+\\rangle^{\\otimes n}$。然后缓慢地作用如下含时哈密顿量\n",
    "\n",
    "$$\n",
    "H(t)=(1-\\frac{t}{T})H_B+(\\frac{t}{T})H_C\n",
    "$$\n",
    "\n",
    "注意到当$t=T$时，$H(T)=H_C$。当选取的$T$足够大时（满足绝热条件），系统将始终处于$H(t)$的瞬时基态上，此时系统的量子态将从初始哈密顿量$H_B$的基态$|\\psi (0)\\rangle$绝热地演化到目标哈密顿量$H_C$的基态$|\\psi (T)\\rangle$上，即\n",
    "\n",
    "$$\n",
    "|\\psi (T)\\rangle=\\mathcal{T}e^{-i\\int^{T}_{0} H(t)dt}|\\psi(0)\\rangle\n",
    "$$\n",
    "\n",
    "也就是说，ansatz线路需要模拟的就是$\\mathcal{T}e^{-i\\int^{T}_{0} H(t)dt}$这一演化过程。接下来我们将对这个式子进行一些近似和化简，使其变为可以在量子线路中实现的形式。\n",
    "\n",
    "考虑如下trotter公式\n",
    "\n",
    "$$\n",
    "\\mathcal{T}e^{-i\\int^T_0 H(t)dt}=\\lim_{N\\rightarrow \\infty}\\prod^N_{l=1}e^{-iH(t_l)\\Delta t},\\quad \\Delta t=\\frac{T}{N},\\quad t_l=l\\Delta t\n",
    "$$\n",
    "\n",
    "略去$O(\\Delta t^2)$项，得到\n",
    "\n",
    "$$\n",
    "\\mathcal{T}e^{-i\\int^T_0 H(t)dt}\\approx \\lim_{N\\rightarrow \\infty}\\prod^N_{l=1}e^{-iH_B(1-t_l/T)\\Delta t}e^{-iH_C t_l\\Delta t/T}\n",
    "$$\n",
    "\n",
    "令$\\beta_l=(1-t_l/T)\\Delta t$，$\\gamma_l=t_l\\Delta t/T$，并取$N$为一个有限大的整数，即得到QAOA的ansatz\n",
    "\n",
    "$$\n",
    "|\\psi(\\gamma,\\beta)\\rangle=\\prod^p_{l=1}e^{-i\\beta_l H_B}e^{-i\\gamma_l H_C}|\\psi_{in}\\rangle\n",
    "$$\n",
    "\n",
    "因此我们需要搭建的ansatz线路由$U_C(\\gamma)$和$U_B(\\beta)$这两个酉变换交替构成，其中$U_C(\\gamma)=e^{-i\\gamma \\sum_{\\langle i,j\\rangle}Z_i Z_j}$可以由`ZZ`门实现，$U_B(\\beta)=e^{-i\\beta \\sum_i X_i}$则相当于在每个量子比特上作用一个`RX`旋转门，$\\gamma$和$\\beta$是可训练的参数。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "搭建$U_C(\\gamma)$对应的量子线路："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def build_hc(g, para):\n",
    "    hc = Circuit()                  # 创建量子线路\n",
    "    for i in g.edges:\n",
    "        hc += ZZ(para).on(i)        # 对图中的每条边作用ZZ门\n",
    "    hc.barrier()                    # 添加Barrier以方便展示线路\n",
    "    return hc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "线路展示："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<div class=\"nb-html-output\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"752.8\" height=\"320\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<rect x=\"0\" y=\"0\" width=\"752.8\" height=\"320\" fill=\"#ffffff\" />\n<text x=\"20.0\" y=\"40.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq0:\n </text>\n<text x=\"20.0\" y=\"100.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq1:\n </text>\n<text x=\"20.0\" y=\"160.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq2:\n </text>\n<text x=\"20.0\" y=\"220.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq3:\n </text>\n<text x=\"20.0\" y=\"280.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq4:\n </text>\n<line x1=\"48.8\" x2=\"732.8\" y1=\"40.0\" y2=\"40.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"732.8\" y1=\"100.0\" y2=\"100.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"732.8\" y1=\"160.0\" y2=\"160.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"732.8\" y1=\"220.0\" y2=\"220.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"732.8\" y1=\"280.0\" y2=\"280.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n\n<rect x=\"72.8\" y=\"20.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"112.8\" y=\"66.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"112.8\" y=\"82.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n\n<rect x=\"172.8\" y=\"20.0\" width=\"80.0\" height=\"280\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"212.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"212.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n<circle cx=\"172.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"252.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"172.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"252.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"280.8\" y=\"20.0\" width=\"80.0\" height=\"160\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"320.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"320.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n<circle cx=\"280.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"360.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"280.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"360.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"388.8\" y=\"80.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"428.8\" y=\"126.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"428.8\" y=\"142.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n\n<rect x=\"488.8\" y=\"140.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"528.8\" y=\"186.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"528.8\" y=\"202.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n\n<rect x=\"588.8\" y=\"200.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"628.8\" y=\"246.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"628.8\" y=\"262.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n<rect x=\"688.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n</svg></div>",
      "text/plain": [
       "<mindquantum.io.display.circuit_svg_drawer.SVGCircuit at 0x7f8534a90490>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pylint: disable=W0104\n",
    "circuit = build_hc(g, 'gamma')\n",
    "circuit.svg()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "搭建$U_B(\\beta)$对应的量子线路："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def build_hb(g, para):\n",
    "    hb = Circuit()                  # 创建量子线路\n",
    "    for i in g.nodes:\n",
    "        hb += RX(para).on(i)        # 对每个节点作用RX门\n",
    "    hb.barrier()                    # 添加Barrier以方便展示线路\n",
    "    return hb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "线路展示："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<div class=\"nb-html-output\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"196.8\" height=\"320\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<rect x=\"0\" y=\"0\" width=\"196.8\" height=\"320\" fill=\"#ffffff\" />\n<text x=\"20.0\" y=\"40.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq0:\n </text>\n<text x=\"20.0\" y=\"100.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq1:\n </text>\n<text x=\"20.0\" y=\"160.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq2:\n </text>\n<text x=\"20.0\" y=\"220.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq3:\n </text>\n<text x=\"20.0\" y=\"280.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq4:\n </text>\n<line x1=\"48.8\" x2=\"176.8\" y1=\"40.0\" y2=\"40.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"176.8\" y1=\"100.0\" y2=\"100.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"176.8\" y1=\"160.0\" y2=\"160.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"176.8\" y1=\"220.0\" y2=\"220.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"176.8\" y1=\"280.0\" y2=\"280.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n\n<rect x=\"72.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"36.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"92.8\" y=\"52.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"72.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"92.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"72.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"92.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"72.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"216.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"92.8\" y=\"232.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"72.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"276.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"92.8\" y=\"292.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n<rect x=\"132.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n</svg></div>",
      "text/plain": [
       "<mindquantum.io.display.circuit_svg_drawer.SVGCircuit at 0x7f8534a668e0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pylint: disable=W0104\n",
    "circuit = build_hb(g, 'beta')\n",
    "circuit.svg()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "实现了一层酉变换$U_B(\\beta) U_C(\\gamma)$的ansatz线路如下所示："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<div class=\"nb-html-output\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"852.8\" height=\"320\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<rect x=\"0\" y=\"0\" width=\"852.8\" height=\"320\" fill=\"#ffffff\" />\n<text x=\"20.0\" y=\"40.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq0:\n </text>\n<text x=\"20.0\" y=\"100.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq1:\n </text>\n<text x=\"20.0\" y=\"160.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq2:\n </text>\n<text x=\"20.0\" y=\"220.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq3:\n </text>\n<text x=\"20.0\" y=\"280.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq4:\n </text>\n<line x1=\"48.8\" x2=\"832.8\" y1=\"40.0\" y2=\"40.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"832.8\" y1=\"100.0\" y2=\"100.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"832.8\" y1=\"160.0\" y2=\"160.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"832.8\" y1=\"220.0\" y2=\"220.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"832.8\" y1=\"280.0\" y2=\"280.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n\n<rect x=\"72.8\" y=\"20.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"112.8\" y=\"66.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"112.8\" y=\"82.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n\n<rect x=\"172.8\" y=\"20.0\" width=\"80.0\" height=\"280\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"212.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"212.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n<circle cx=\"172.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"252.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"172.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"252.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"280.8\" y=\"20.0\" width=\"80.0\" height=\"160\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"320.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"320.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n<circle cx=\"280.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"360.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"280.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"360.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"388.8\" y=\"80.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"428.8\" y=\"126.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"428.8\" y=\"142.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n\n<rect x=\"488.8\" y=\"140.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"528.8\" y=\"186.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"528.8\" y=\"202.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n\n<rect x=\"588.8\" y=\"200.0\" width=\"80.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"628.8\" y=\"246.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"628.8\" y=\"262.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ngamma\n </text>\n\n<rect x=\"688.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"728.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"748.8\" y=\"36.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"748.8\" y=\"52.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"728.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"748.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"748.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"728.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"748.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"748.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"728.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"748.8\" y=\"216.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"748.8\" y=\"232.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n\n<rect x=\"728.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"748.8\" y=\"276.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"748.8\" y=\"292.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nbeta\n </text>\n\n<rect x=\"788.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n</svg></div>",
      "text/plain": [
       "<mindquantum.io.display.circuit_svg_drawer.SVGCircuit at 0x7f853477d2b0>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pylint: disable=W0104\n",
    "circuit = build_hc(g, 'gamma') + build_hb(g, 'beta')\n",
    "circuit.svg()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "为了使得最后优化的结果足够准确，我们需要将量子线路重复多次，因此我们通过如下函数搭建多层的训练网络："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def build_ansatz(g, p):                    # g是max-cut问题的图，p是ansatz线路的层数\n",
    "    circ = Circuit()                       # 创建量子线路\n",
    "    for i in range(p):\n",
    "        circ += build_hc(g, f'g{i}')       # 添加Uc对应的线路，参数记为g0、g1、g2...\n",
    "        circ += build_hb(g, f'b{i}')       # 添加Ub对应的线路，参数记为b0、b1、b2...\n",
    "    return circ"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "构建图对应的哈密顿量$H_C=\\sum_{(i,j)\\in C}(Z_iZ_j-1)/2$（忽略常数项和系数）："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def build_ham(g):\n",
    "    ham = QubitOperator()\n",
    "    for i in g.edges:\n",
    "        ham += QubitOperator(f'Z{i[0]} Z{i[1]}')  # 生成哈密顿量Hc\n",
    "    return ham"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 生成完整的量子线路和图所对应的哈密顿量\n",
    "\n",
    "这里我们选择`p = 4`，表示选用4层的QAOA量子线路，`ansatz`是求解该问题的量子线路，`init_state_circ`是将量子态制备到均匀叠加态（$H_B$的基态）上的量子线路。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<div class=\"nb-html-output\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"2220.8\" height=\"320\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<rect x=\"0\" y=\"0\" width=\"2220.8\" height=\"320\" fill=\"#ffffff\" />\n<text x=\"20.0\" y=\"40.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq0:\n </text>\n<text x=\"20.0\" y=\"100.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq1:\n </text>\n<text x=\"20.0\" y=\"160.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq2:\n </text>\n<text x=\"20.0\" y=\"220.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq3:\n </text>\n<text x=\"20.0\" y=\"280.0\" font-size=\"16px\" dominant-baseline=\"middle\" text-anchor=\"start\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#252b3a\" >\nq4:\n </text>\n<line x1=\"48.8\" x2=\"2200.8\" y1=\"40.0\" y2=\"40.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"2200.8\" y1=\"100.0\" y2=\"100.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"2200.8\" y1=\"160.0\" y2=\"160.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"2200.8\" y1=\"220.0\" y2=\"220.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"48.8\" x2=\"2200.8\" y1=\"280.0\" y2=\"280.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n\n<rect x=\"72.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#5e7ce0\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"40.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nH\n </text>\n\n\n<rect x=\"72.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#5e7ce0\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"100.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nH\n </text>\n\n\n<rect x=\"72.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#5e7ce0\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"160.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nH\n </text>\n\n\n<rect x=\"72.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#5e7ce0\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"220.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nH\n </text>\n\n\n<rect x=\"72.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#5e7ce0\" fill-opacity=\"1\" />\n<text x=\"92.8\" y=\"280.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nH\n </text>\n\n\n<rect x=\"132.8\" y=\"20.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"152.8\" y=\"66.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"152.8\" y=\"82.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng0\n </text>\n\n\n<rect x=\"192.8\" y=\"20.0\" width=\"40.0\" height=\"280\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"212.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"212.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng0\n </text>\n<circle cx=\"192.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"232.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"192.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"232.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"260.8\" y=\"20.0\" width=\"40.0\" height=\"160\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"280.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"280.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng0\n </text>\n<circle cx=\"260.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"300.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"260.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"300.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"328.8\" y=\"80.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"348.8\" y=\"126.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"348.8\" y=\"142.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng0\n </text>\n\n\n<rect x=\"388.8\" y=\"140.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"408.8\" y=\"186.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"408.8\" y=\"202.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng0\n </text>\n\n\n<rect x=\"448.8\" y=\"200.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"468.8\" y=\"246.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"468.8\" y=\"262.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng0\n </text>\n\n<rect x=\"508.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"548.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"568.8\" y=\"36.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"568.8\" y=\"52.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb0\n </text>\n\n\n<rect x=\"548.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"568.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"568.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb0\n </text>\n\n\n<rect x=\"548.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"568.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"568.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb0\n </text>\n\n\n<rect x=\"548.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"568.8\" y=\"216.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"568.8\" y=\"232.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb0\n </text>\n\n\n<rect x=\"548.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"568.8\" y=\"276.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"568.8\" y=\"292.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb0\n </text>\n\n<rect x=\"608.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"648.8\" y=\"20.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"668.8\" y=\"66.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"668.8\" y=\"82.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng1\n </text>\n\n\n<rect x=\"708.8\" y=\"20.0\" width=\"40.0\" height=\"280\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"728.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"728.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng1\n </text>\n<circle cx=\"708.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"748.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"708.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"748.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"776.8\" y=\"20.0\" width=\"40.0\" height=\"160\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"796.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"796.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng1\n </text>\n<circle cx=\"776.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"816.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"776.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"816.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"844.8\" y=\"80.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"864.8\" y=\"126.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"864.8\" y=\"142.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng1\n </text>\n\n\n<rect x=\"904.8\" y=\"140.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"924.8\" y=\"186.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"924.8\" y=\"202.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng1\n </text>\n\n\n<rect x=\"964.8\" y=\"200.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"984.8\" y=\"246.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"984.8\" y=\"262.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng1\n </text>\n\n<rect x=\"1024.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"1064.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1084.8\" y=\"36.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1084.8\" y=\"52.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb1\n </text>\n\n\n<rect x=\"1064.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1084.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1084.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb1\n </text>\n\n\n<rect x=\"1064.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1084.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1084.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb1\n </text>\n\n\n<rect x=\"1064.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1084.8\" y=\"216.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1084.8\" y=\"232.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb1\n </text>\n\n\n<rect x=\"1064.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1084.8\" y=\"276.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1084.8\" y=\"292.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb1\n </text>\n\n<rect x=\"1124.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"1164.8\" y=\"20.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1184.8\" y=\"66.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1184.8\" y=\"82.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng2\n </text>\n\n\n<rect x=\"1224.8\" y=\"20.0\" width=\"40.0\" height=\"280\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1244.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1244.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng2\n </text>\n<circle cx=\"1224.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1264.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1224.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1264.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"1292.8\" y=\"20.0\" width=\"40.0\" height=\"160\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1312.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1312.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng2\n </text>\n<circle cx=\"1292.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1332.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1292.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1332.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"1360.8\" y=\"80.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1380.8\" y=\"126.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1380.8\" y=\"142.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng2\n </text>\n\n\n<rect x=\"1420.8\" y=\"140.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1440.8\" y=\"186.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1440.8\" y=\"202.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng2\n </text>\n\n\n<rect x=\"1480.8\" y=\"200.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1500.8\" y=\"246.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1500.8\" y=\"262.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng2\n </text>\n\n<rect x=\"1540.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"1580.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1600.8\" y=\"36.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1600.8\" y=\"52.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb2\n </text>\n\n\n<rect x=\"1580.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1600.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1600.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb2\n </text>\n\n\n<rect x=\"1580.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1600.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1600.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb2\n </text>\n\n\n<rect x=\"1580.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1600.8\" y=\"216.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1600.8\" y=\"232.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb2\n </text>\n\n\n<rect x=\"1580.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1600.8\" y=\"276.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"1600.8\" y=\"292.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb2\n </text>\n\n<rect x=\"1640.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"1680.8\" y=\"20.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1700.8\" y=\"66.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1700.8\" y=\"82.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng3\n </text>\n\n\n<rect x=\"1740.8\" y=\"20.0\" width=\"40.0\" height=\"280\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1760.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1760.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng3\n </text>\n<circle cx=\"1740.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1780.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1740.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1780.8\" cy=\"280.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"1808.8\" y=\"20.0\" width=\"40.0\" height=\"160\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1828.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1828.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng3\n </text>\n<circle cx=\"1808.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1848.8\" cy=\"40.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1808.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n<circle cx=\"1848.8\" cy=\"160.0\" r=\"4\" fill=\"#fac209\" />\n\n<rect x=\"1876.8\" y=\"80.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1896.8\" y=\"126.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1896.8\" y=\"142.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng3\n </text>\n\n\n<rect x=\"1936.8\" y=\"140.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"1956.8\" y=\"186.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"1956.8\" y=\"202.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng3\n </text>\n\n\n<rect x=\"1996.8\" y=\"200.0\" width=\"40.0\" height=\"100\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"2016.8\" y=\"246.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nZZ\n </text>\n<text x=\"2016.8\" y=\"262.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\ng3\n </text>\n\n<rect x=\"2056.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n\n<rect x=\"2096.8\" y=\"20.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"2116.8\" y=\"36.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"2116.8\" y=\"52.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb3\n </text>\n\n\n<rect x=\"2096.8\" y=\"80.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"2116.8\" y=\"96.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"2116.8\" y=\"112.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb3\n </text>\n\n\n<rect x=\"2096.8\" y=\"140.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"2116.8\" y=\"156.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"2116.8\" y=\"172.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb3\n </text>\n\n\n<rect x=\"2096.8\" y=\"200.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"2116.8\" y=\"216.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"2116.8\" y=\"232.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb3\n </text>\n\n\n<rect x=\"2096.8\" y=\"260.0\" width=\"40.0\" height=\"40\" rx=\"4\" ry=\"4\" stroke=\"#ffffff\" stroke-width=\"0\" fill=\"#fac209\" fill-opacity=\"1\" />\n<text x=\"2116.8\" y=\"276.0\" font-size=\"20px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nRX\n </text>\n<text x=\"2116.8\" y=\"292.0\" font-size=\"14.0px\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"Arial\" font-weight=\"normal\" fill=\"#ffffff\" >\nb3\n </text>\n\n<rect x=\"2156.8\" y=\"20.0\" width=\"20\" height=\"280\" fill=\"gray\" fill-opacity=\"0.8\" />\n</svg></div>",
      "text/plain": [
       "<mindquantum.io.display.circuit_svg_drawer.SVGCircuit at 0x7f85347a47f0>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pylint: disable=W0104\n",
    "p = 4\n",
    "ham = Hamiltonian(build_ham(g))              # 生成哈密顿量\n",
    "init_state_circ = UN(H, g.nodes)             # 生成均匀叠加态，即对所有量子比特作用H门\n",
    "ansatz = build_ansatz(g, p)                  # 生成ansatz线路\n",
    "circ = init_state_circ + ansatz              # 将初始化线路与ansatz线路组合成一个线路\n",
    "circ.svg()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 搭建待训练量子神经网络\n",
    "\n",
    "由于该问题不需要编码层量子线路，我们这里使用`MQAnsatzOnlyLayer`作为待训练的量子神经网络，并采用`Adam`优化器。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import mindspore as ms\n",
    "ms.context.set_context(mode=ms.context.PYNATIVE_MODE, device_target=\"CPU\")\n",
    "\n",
    "sim = Simulator('projectq', circ.n_qubits)                     # 创建模拟器，backend使用‘projectq’，能模拟5个比特（'circ'线路中包含的比特数）\n",
    "grad_ops = sim.get_expectation_with_grad(ham, circ)            # 获取计算变分量子线路的期望值和梯度的算子\n",
    "net = MQAnsatzOnlyLayer(grad_ops)                              # 生成待训练的神经网络\n",
    "opti = nn.Adam(net.trainable_params(), learning_rate=0.05)     # 设置针对网络中所有可训练参数、学习率为0.05的Adam优化器\n",
    "train_net = nn.TrainOneStepCell(net, opti)                     # 对神经网络进行一步训练"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 训练并展示结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train step: 0 , cut: [3.0001478]\n",
      "train step: 10 , cut: [4.1718774]\n",
      "train step: 20 , cut: [4.6871986]\n",
      "train step: 30 , cut: [4.7258005]\n",
      "train step: 40 , cut: [4.804503]\n",
      "train step: 50 , cut: [4.8477592]\n",
      "train step: 60 , cut: [4.8705964]\n",
      "train step: 70 , cut: [4.9060946]\n",
      "train step: 80 , cut: [4.933446]\n",
      "train step: 90 , cut: [4.9356637]\n",
      "train step: 100 , cut: [4.938308]\n",
      "train step: 110 , cut: [4.9390197]\n",
      "train step: 120 , cut: [4.939068]\n",
      "train step: 130 , cut: [4.9392157]\n",
      "train step: 140 , cut: [4.939249]\n",
      "train step: 150 , cut: [4.939247]\n",
      "train step: 160 , cut: [4.939255]\n",
      "train step: 170 , cut: [4.939257]\n",
      "train step: 180 , cut: [4.939257]\n",
      "train step: 190 , cut: [4.939257]\n"
     ]
    }
   ],
   "source": [
    "for i in range(200):\n",
    "    cut = (len(g.edges) - train_net()) / 2      # 将神经网络训练一步并计算得到的结果（切割边数）。注意：每当'train_net()'运行一次，神经网络就训练了一步\n",
    "    if i%10 == 0:\n",
    "        print(\"train step:\", i, \", cut:\", cut)  # 每训练10步，打印当前训练步数和当前得到的切割边数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "根据上面的训练结果我们发现，该问题哈密顿量的基态能量对应的边切割数趋近于5。\n",
    "\n",
    "### 最优参数\n",
    "\n",
    "前面我们通过训练得到了量子线路中参数的最优值，下面，我们将最优参数提取出来并存储为字典类型，与之前线路中命名的参数一一对应。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'g0': 0.22448167, 'b0': -1.1390871, 'g1': 0.45314747, 'b1': -0.94472605, 'g2': 0.5338268, 'b2': -0.67756957, 'g3': 0.58400834, 'b3': -0.38243017}\n"
     ]
    }
   ],
   "source": [
    "pr = dict(zip(ansatz.params_name, net.weight.asnumpy())) # 获取线路参数\n",
    "print(pr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 概率图\n",
    "\n",
    "我们将最优参数代入量子线路，通过对量子线路进行1000次采样，画出最终量子态在计算基矢下的概率分布："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<div class=\"nb-html-output\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"430.0\" height=\"687.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<rect x=\"0\" y=\"0\" width=\"430.0\" height=\"687.0\" fill=\"#ffffff\" />\n<text x=\"10\" y=\"17.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" >\nShots:\n 1000\n </text>\n<text x=\"10\" y=\"31.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" >\nKeys: q0 q1 q2 q3 q4\n </text>\n<line x1=\"60.0\" x2=\"420.0\" y1=\"62.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"60.0\" x2=\"60.0\" y1=\"55.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<text x=\"62.0\" y=\"60.0\" font-size=\"12px\" dominant-baseline=\"bottom\" text-anchor=\"start\" fill=\"#575d6c\" >\n0.0\n </text>\n<line x1=\"60.0\" x2=\"60.0\" y1=\"62.0\" y2=\"677.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<line x1=\"120.0\" x2=\"120.0\" y1=\"55.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<text x=\"122.0\" y=\"60.0\" font-size=\"12px\" dominant-baseline=\"bottom\" text-anchor=\"start\" fill=\"#575d6c\" >\n0.05\n </text>\n<line x1=\"120.0\" x2=\"120.0\" y1=\"62.0\" y2=\"677.0\" stroke=\"#dfe1e6\" stroke-width=\"1\" />\n<line x1=\"180.0\" x2=\"180.0\" y1=\"55.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<text x=\"182.0\" y=\"60.0\" font-size=\"12px\" dominant-baseline=\"bottom\" text-anchor=\"start\" fill=\"#575d6c\" >\n0.1\n </text>\n<line x1=\"180.0\" x2=\"180.0\" y1=\"62.0\" y2=\"677.0\" stroke=\"#dfe1e6\" stroke-width=\"1\" />\n<line x1=\"240.0\" x2=\"240.0\" y1=\"55.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<text x=\"242.0\" y=\"60.0\" font-size=\"12px\" dominant-baseline=\"bottom\" text-anchor=\"start\" fill=\"#575d6c\" >\n0.151\n </text>\n<line x1=\"240.0\" x2=\"240.0\" y1=\"62.0\" y2=\"677.0\" stroke=\"#dfe1e6\" stroke-width=\"1\" />\n<line x1=\"300.0\" x2=\"300.0\" y1=\"55.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<text x=\"302.0\" y=\"60.0\" font-size=\"12px\" dominant-baseline=\"bottom\" text-anchor=\"start\" fill=\"#575d6c\" >\n0.201\n </text>\n<line x1=\"300.0\" x2=\"300.0\" y1=\"62.0\" y2=\"677.0\" stroke=\"#dfe1e6\" stroke-width=\"1\" />\n<line x1=\"360.0\" x2=\"360.0\" y1=\"55.0\" y2=\"62.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<text x=\"362.0\" y=\"60.0\" font-size=\"12px\" dominant-baseline=\"bottom\" text-anchor=\"start\" fill=\"#575d6c\" >\n0.251\n </text>\n<line x1=\"360.0\" x2=\"360.0\" y1=\"62.0\" y2=\"677.0\" stroke=\"#dfe1e6\" stroke-width=\"1\" />\n<text x=\"51.0\" y=\"85.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n00000\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"85.0\" y2=\"85.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"73.0\" width=\"4.780876494023905\" height=\"24\" id=\"bar_0_1648091658581991154\" fill=\"#5e7ce0\" />\n<text x=\"74.7808764940239\" y=\"85.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_0_1648091658582028920\" fill-opacity=\"0\" >\n4\n </text>\n<text x=\"51.0\" y=\"115.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n00001\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"115.0\" y2=\"115.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"103.0\" width=\"2.3904382470119523\" height=\"24\" id=\"bar_1_1648091658582066518\" fill=\"#16acff\" />\n<text x=\"72.39043824701196\" y=\"115.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_1_1648091658582090219\" fill-opacity=\"0\" >\n2\n </text>\n<text x=\"51.0\" y=\"145.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n00011\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"145.0\" y2=\"145.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"133.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_2_1648091658582122837\" fill=\"#5e7ce0\" />\n<text x=\"71.19521912350598\" y=\"145.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_2_1648091658582144013\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"175.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n00100\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"175.0\" y2=\"175.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"163.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_3_1648091658582177044\" fill=\"#16acff\" />\n<text x=\"71.19521912350598\" y=\"175.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_3_1648091658582198611\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"205.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n00101\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"205.0\" y2=\"205.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"193.0\" width=\"7.171314741035856\" height=\"24\" id=\"bar_4_1648091658582231023\" fill=\"#5e7ce0\" />\n<text x=\"77.17131474103586\" y=\"205.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_4_1648091658582251624\" fill-opacity=\"0\" >\n6\n </text>\n<text x=\"51.0\" y=\"235.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n01001\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"235.0\" y2=\"235.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"223.0\" width=\"300.0\" height=\"24\" id=\"bar_5_1648091658582282665\" fill=\"#16acff\" />\n<text x=\"370.0\" y=\"235.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_5_1648091658582313799\" fill-opacity=\"0\" >\n251\n </text>\n<text x=\"51.0\" y=\"265.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n01010\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"265.0\" y2=\"265.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"253.0\" width=\"3.585657370517928\" height=\"24\" id=\"bar_6_1648091658582345515\" fill=\"#5e7ce0\" />\n<text x=\"73.58565737051794\" y=\"265.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_6_1648091658582365552\" fill-opacity=\"0\" >\n3\n </text>\n<text x=\"51.0\" y=\"295.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n01011\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"295.0\" y2=\"295.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"283.0\" width=\"262.9482071713147\" height=\"24\" id=\"bar_7_1648091658582407326\" fill=\"#16acff\" />\n<text x=\"332.9482071713147\" y=\"295.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_7_1648091658582428531\" fill-opacity=\"0\" >\n220\n </text>\n<text x=\"51.0\" y=\"325.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n01100\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"325.0\" y2=\"325.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"313.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_8_1648091658582459752\" fill=\"#5e7ce0\" />\n<text x=\"71.19521912350598\" y=\"325.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_8_1648091658582485868\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"355.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n01101\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"355.0\" y2=\"355.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"343.0\" width=\"3.585657370517928\" height=\"24\" id=\"bar_9_1648091658582520442\" fill=\"#16acff\" />\n<text x=\"73.58565737051794\" y=\"355.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_9_1648091658582540724\" fill-opacity=\"0\" >\n3\n </text>\n<text x=\"51.0\" y=\"385.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n01110\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"385.0\" y2=\"385.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"373.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_10_1648091658582571835\" fill=\"#5e7ce0\" />\n<text x=\"71.19521912350598\" y=\"385.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_10_1648091658582597762\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"415.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n10010\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"415.0\" y2=\"415.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"403.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_11_1648091658582631688\" fill=\"#16acff\" />\n<text x=\"71.19521912350598\" y=\"415.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_11_1648091658582654386\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"445.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n10011\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"445.0\" y2=\"445.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"433.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_12_1648091658582685274\" fill=\"#5e7ce0\" />\n<text x=\"71.19521912350598\" y=\"445.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_12_1648091658582705454\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"475.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n10100\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"475.0\" y2=\"475.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"463.0\" width=\"296.4143426294821\" height=\"24\" id=\"bar_13_1648091658582740479\" fill=\"#16acff\" />\n<text x=\"366.4143426294821\" y=\"475.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_13_1648091658582760770\" fill-opacity=\"0\" >\n248\n </text>\n<text x=\"51.0\" y=\"505.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n10101\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"505.0\" y2=\"505.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"493.0\" width=\"2.3904382470119523\" height=\"24\" id=\"bar_14_1648091658582793844\" fill=\"#5e7ce0\" />\n<text x=\"72.39043824701196\" y=\"505.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_14_1648091658582813931\" fill-opacity=\"0\" >\n2\n </text>\n<text x=\"51.0\" y=\"535.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n10110\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"535.0\" y2=\"535.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"523.0\" width=\"295.2191235059761\" height=\"24\" id=\"bar_15_1648091658582857385\" fill=\"#16acff\" />\n<text x=\"365.2191235059761\" y=\"535.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_15_1648091658582881771\" fill-opacity=\"0\" >\n247\n </text>\n<text x=\"51.0\" y=\"565.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n11000\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"565.0\" y2=\"565.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"553.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_16_1648091658582917895\" fill=\"#5e7ce0\" />\n<text x=\"71.19521912350598\" y=\"565.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_16_1648091658582940798\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"595.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n11001\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"595.0\" y2=\"595.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"583.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_17_1648091658582972374\" fill=\"#16acff\" />\n<text x=\"71.19521912350598\" y=\"595.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_17_1648091658582995706\" fill-opacity=\"0\" >\n1\n </text>\n<text x=\"51.0\" y=\"625.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n11010\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"625.0\" y2=\"625.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"613.0\" width=\"5.9760956175298805\" height=\"24\" id=\"bar_18_1648091658583026424\" fill=\"#5e7ce0\" />\n<text x=\"75.97609561752988\" y=\"625.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_18_1648091658583046457\" fill-opacity=\"0\" >\n5\n </text>\n<text x=\"51.0\" y=\"655.0\" font-size=\"12px\" dominant-baseline=\"middle\" text-anchor=\"end\" fill=\"#575d6c\" >\n11111\n </text>\n<line x1=\"53.0\" x2=\"60.0\" y1=\"655.0\" y2=\"655.0\" stroke=\"#adb0b8\" stroke-width=\"1\" />\n<rect x=\"60.0\" y=\"643.0\" width=\"1.1952191235059761\" height=\"24\" id=\"bar_19_1648091658583082324\" fill=\"#16acff\" />\n<text x=\"71.19521912350598\" y=\"655.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"start\" fill=\"#575d6c\" id=\"bar_text_19_1648091658583105391\" fill-opacity=\"0\" >\n1\n </text>\n<animate xlink:href=\"#bar_0_1648091658581991154\" attributeName=\"width\" from=\"0\" to=\"4.780876494023905\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 4.780876494023905\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_1_1648091658582066518\" attributeName=\"width\" from=\"0\" to=\"2.3904382470119523\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 2.3904382470119523\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_2_1648091658582122837\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_3_1648091658582177044\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_4_1648091658582231023\" attributeName=\"width\" from=\"0\" to=\"7.171314741035856\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 7.171314741035856\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_5_1648091658582282665\" attributeName=\"width\" from=\"0\" to=\"300.0\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 300.0\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_6_1648091658582345515\" attributeName=\"width\" from=\"0\" to=\"3.585657370517928\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 3.585657370517928\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_7_1648091658582407326\" attributeName=\"width\" from=\"0\" to=\"262.9482071713147\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 262.9482071713147\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_8_1648091658582459752\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_9_1648091658582520442\" attributeName=\"width\" from=\"0\" to=\"3.585657370517928\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 3.585657370517928\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_10_1648091658582571835\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_11_1648091658582631688\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_12_1648091658582685274\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_13_1648091658582740479\" attributeName=\"width\" from=\"0\" to=\"296.4143426294821\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 296.4143426294821\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_14_1648091658582793844\" attributeName=\"width\" from=\"0\" to=\"2.3904382470119523\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 2.3904382470119523\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_15_1648091658582857385\" attributeName=\"width\" from=\"0\" to=\"295.2191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 295.2191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_16_1648091658582917895\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_17_1648091658582972374\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_18_1648091658583026424\" attributeName=\"width\" from=\"0\" to=\"5.9760956175298805\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 5.9760956175298805\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_19_1648091658583082324\" attributeName=\"width\" from=\"0\" to=\"1.1952191235059761\" dur=\"0.3s\" calcMode=\"spline\" values=\"0; 1.1952191235059761\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" />\n<animate xlink:href=\"#bar_5_1648091658582282665\" attributeName=\"fill\" from=\"#16acff\" to=\"#fac209\" dur=\"0.15s\" calcMode=\"spline\" values=\"#16acff; #fac209\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_0_1648091658582028920\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_1_1648091658582090219\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_2_1648091658582144013\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_3_1648091658582198611\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_4_1648091658582251624\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_5_1648091658582313799\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_6_1648091658582365552\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_7_1648091658582428531\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_8_1648091658582485868\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_9_1648091658582540724\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_10_1648091658582597762\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_11_1648091658582654386\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_12_1648091658582705454\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_13_1648091658582760770\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_14_1648091658582813931\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_15_1648091658582881771\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_16_1648091658582940798\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_17_1648091658582995706\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_18_1648091658583046457\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<animate xlink:href=\"#bar_text_19_1648091658583105391\" attributeName=\"fill-opacity\" from=\"0\" to=\"1\" dur=\"0.15s\" calcMode=\"spline\" values=\"0; 1\" keyTimes=\"0; 1\" keySplines=\"0.42 0 1 0.8;\" fill=\"freeze\" begin=\"0.3s\" />\n<text x=\"217.5\" y=\"41.0\" font-size=\"14px\" dominant-baseline=\"middle\" text-anchor=\"middle\" >\nprobability\n </text>\n</svg></div>",
      "text/plain": [
       "<mindquantum.io.display.measure_res_svg_drawer.SVGMeasure at 0x7f8534a24d00>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pylint: disable=W0104\n",
    "circ.measure_all()                               # 为线路中所有比特添加测量门\n",
    "sim.sampling(circ, pr=pr, shots=1000).svg()      # 运行线路1000次并打印结果"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "根据概率分布图我们发现，该Max-Cut问题具有四个简并解，每个解对应的概率大概为25%。\n",
    "\n",
    "- `01001`：编号为1、2、4的顶点在左边，编号为0、3的顶点在右边。\n",
    "- `10110`：编号为0、3的顶点在左边，编号为1、2、4的顶点在右边。\n",
    "- `01011`：编号为2、4的顶点在左边，编号为0、1、3的顶点在右边。\n",
    "- `10100`：编号为0、1、3的顶点在左边，编号为2、4的顶点在右边。\n",
    "\n",
    "可以发现，以上结果与先前通过穷举法得到的结果相符。\n",
    "\n",
    "## 总结\n",
    "\n",
    "这里我们通过量子近似优化算法来解决了Max-Cut问题，并得到了案例中的图对应的最大切割方案。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 参考文献\n",
    "\n",
    "[1] Edward Farhi, Jeffrey Goldstone, and Sam Gutmann. [A Quantum Approximate Optimization Algorithm](https://arxiv.org/pdf/1411.4028.pdf)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "d62cf896b9ca57de08105ce3983377439eacacf6f6599f9150bf400edf4fa4b8"
  },
  "kernelspec": {
   "display_name": "Python 3.7.5 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
